{% extends "orga/base.html" %}

{% load compress %}
{% load i18n %}
{% load review_score %}
{% load rules %}
{% load static %}

{% block scripts %}
    {% compress js %}
        <script src="{% static "orga/js/submission_filter.js" %}"></script>
    {% endcompress %}
{% endblock scripts %}

{% block extra_title %}{% translate "Reviews" %} :: {% endblock extra_title %}

{% block content %}
    {% has_perm "base.reviewer_list_speakerprofile" request.user request.event as can_view_speakers %}
    <div class="alert alert-info">
        {% if next_submission %}
            {% blocktranslate trimmed count count=missing_reviews %}
                Or review the missing proposal here.
            {% plural %}
                Or review the missing {{ count }} proposals one-by-one.
            {% endblocktranslate %}
            <a href="{{ next_submission.orga_urls.reviews }}" class="btn btn-outline-info btn-xs ml-2">
                <i class="fa fa-arrow-right"></i>
            </a>
        {% else %}
            {% translate "You’ve got no proposals left to review!" %}
        {% endif %}
    </div>

    {% include "orga/includes/review_filter_form.html" %}

    <form method="post">
        {% csrf_token %}
        <div class="table-responsive-sm">
            <table class="table table-sm table-flip table-sticky">
                <thead>
                    <tr>
                        <th>{% translate "Title" %}</th>
                        {% if can_view_speakers %}<th>{{ phrases.schedule.speakers }}</th>{% endif %}
                        {% for category in categories %}<th>{{ category.name }}</th>{% endfor %}
                        <th>{% translate "Comment" %}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for row in table %}
                        <tr>
                            <td>
                                <a href="{{ row.submission.orga_urls.base }}">{{ row.submission.title }}</a>
                            </td>
                            {% if can_view_speakers %}
                                <td>
                                    {% for speaker in row.submission.speakers.all %}
                                        {% include "orga/includes/user_name.html" with user=speaker lightbox=True %}<br>
                                    {% endfor %}
                                </td>
                            {% endif %}
                            {% for score in row.score_fields %}
                                <td class="pt-2">
                                    {% if score %}
                                        {{ score.as_field_group }}
                                    {% endif %}
                                </td>
                            {% endfor %}
                            <td class="pt-2">
                                {{ row.form.text.as_field_group }}
                            </td>
                        </tr>
                    {% empty %}
                        <tr>
                            <td colspan=10>{% translate "You don’t seem to have any proposals yet." %}</td>
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        <div id="submitBar">
            <button type="submit" class="btn btn-success">{{ phrases.base.save }}</button>
        </div>
    </form>
{% endblock content %}
